<%@ page language="java" import="java.util.*" pageEncoding="utf-8"
	isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
    String path = request.getContextPath();
			String basePath = request.getScheme() + "://"
					+ request.getServerName() + ":" + request.getServerPort()
					+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>系统消息列表</title>

<script type="text/javascript" src="<%=request.getContextPath()%>/easyui/jquery.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/easyui/locale/easyui-lang-zh_CN.js"></script>
<link href="<%=request.getContextPath()%>/easyui/themes/default/easyui.css" rel="stylesheet" type="text/css" />
<link href="<%=request.getContextPath()%>/easyui/themes/icon.css" rel="stylesheet" type="text/css" />
<link href="<%=request.getContextPath()%>/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-2.1.4.min.js"></script>
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/jPages.css">
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/animate.css">
<script src="<%=request.getContextPath()%>/js/jquery-1.8.2.min.js"></script>
<script src="<%=request.getContextPath()%>/js/jPages.js"></script>
<style >
  /*   .toolbar1 table{
    width: 552px;
    } */
    input{
       border: solid 1px #d7a372;
    }
</style>
<script type="text/javascript">
$(function(){  
	$("div.holder").jPages({  
	  containerID : "item", 
	  first:"首页", 
	  previous : "上一页",  
	  next : "下一页",
	  last:"尾页",  
	  perPage : 10,  
	  //delay : 100,
	  //动画效果
	  //animation:"bounceInLeft"
	});  
	
	$("#selectAll").click(function() {
		if($("#selectAll").is(":checked")){
			$("input[name=select]").prop("checked","checked");
		}else{
			$("input[name=select]").attr("checked",false);
		}
	});
	
	$(".delete").click(function() {
		var str = new Array();
		$("input[name=select]:checked").each(function(index,domEle){
			var idd = $(domEle).parent().parent().find("input[type=hidden]").val();				
			str.push(idd);
	    }); 
	    if(str == null || str == ""){
	    	alert("请选择要删除的消息！");
	    	return;
	    }
	    $(".tip").fadeIn(500);
	    $(".sure").click(function(){
	    	str = str.join(","),
		    window.location.href="/htx-backer/deleteMessage?idd="+str;
		});
	});
	/* $(".imports").click(function() {//导入
		$('#excelFile').click();
	}); */
	
 });  
</script>
<script type="text/javascript">
$(document).ready(function(){
  $(".click").click(function(){
 	 $(".tip").fadeIn(200);
  });
  
  $(".cancel").click(function(){
	  $(".tip").fadeOut(100);
  });
});
</script>
</head>

<body>
	<div class="place">
		<span>位置：</span>
		<ul class="placeul">
			<li><ema href="javascript:void">首页</em></li>
			<li><ema href="javascript:void">内容管理</em></li>
			<li><ema href="javascript:void">消息管理</em></li>
		</ul>
	</div>
	<div class="rightinfo">
	  <div >
				<table>
					<form action="<%=request.getContextPath()%>/selectMessageList" method="post" name="serch">
						<tr>
							<td class="zi"><span>添加时间：</span></td>
							<td><input type="date" name="startTime" />至<input type="date" name="endTime" /></td>
							<td class="zi" ><span >状态：</span></td>
							<td><select name="status">
									<option selected="selected" value="">请选择</option>
									<option value="待发送">待发送</option>
									<option value="已发送">已发送</option>
							</select></td>
							<td></td>
							<td class="zi" ><span >消息标题：</span></td>
							<td><input type="text" name="title" /></td>
							<td><input type="submit" value="查询" style="background-color: #dca571; padding: 7px; border-radius: 5%;margin-left:2px;height: 35px;" class="button" /></td>
						</tr>
					</form>
				</table>
			</div>
		<div class="tools">
			<ul class="toolbar">
				<li class="delete"><span><img src="<%=request.getContextPath()%>/images/t03.png" /></span>删除</li>
				<a href="/htx-backer/ui/message/addMessage.jsp"><li><span><img src="<%=request.getContextPath()%>/images/t01.png" /></span>添加</li></a>
<%-- 											<li class="backups"><span><img src="<%=request.getContextPath()%>/images/t01.png" /></span>备份</li>
							<li class="recovery"><span><img src="<%=request.getContextPath()%>/images/t02.png" /></span>恢复</li> --%>
			</ul>
		</div>
		<table class="tablelist">
			<thead>
				<tr>
					<th><input type="checkbox" value="" id="selectAll" /></th>
					<th>消息标题</th>
					<th>推送范围</th>
					<th>发布人</th>
					<th>推送时间</th>
					<th>状态</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody class="tb" id="item">
				<c:forEach items="${lists}" var="data">
					<tr>
						<td><input name="select" type="checkbox" value="" /></td>
						<input type="hidden" value="${data.id}"></input>
						<td>${data.title}</td>
						<td>${data.scope}</td>
						<td>${data.username}</td>
						<td>${data.push_time} </td>
						<td>${data.status}</td>
						<td>
							<c:if test="${data.status == '待发送'}">
								<a href="/htx-backer/selectMessageList?updateid=${data.id}" style="cursor:pointer;color:blue;font-size:14px;font-weight:bold;">编辑</a>
							</c:if>
							<c:if test="${data.status == '已发送'}">
								<a href="/htx-backer/selectMessageList?id=${data.id}" style="cursor:pointer;color:blue;font-size:14px;font-weight:bold;">查看</a>
							</c:if>
						</td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
		<div style="clear:both;"></div>
		<!-- 分页的页码 -->
		<div class="holder"></div>
		共${nums}条记录
		<div class="tip">
			<div class="tiptop">
				<span>提示信息</span>
			</div>
			<div class="tipinfo">
				<span><img src="<%=request.getContextPath()%>/images/ticon.png" /></span>
				<div class="tipright">
					<p>是否确认删除 ？</p>
					<cite>如果是请点击确定按钮 ，否则请点取消。</cite>
				</div>
			</div>
			<div class="tipbtn">
				<input name="" type="button" class="sure" value="确定"/>&nbsp;<input name="" type="button" class="cancel" value="取消" />
			</div>
		</div>
	</div>
	<script type="text/javascript">
		$('.tablelist tbody tr:odd').addClass('odd');
		 $(".backups").click(function(){
			  $.ajax({
	  				type:"get",
	  				url:"/htx-backer/backups", 
	  				data:{
	  					name:"system_message"
	  				},
	  				success:function(data){
	  					if(data == "OK"){
	  					 	alert("备份成功!");
	  					}else{
	  						alert("备份失败!");
	  					}
	  					
	  				},
	  				fail:function(e){
	  					alert("fail");
	  				},
	  				error:function(e){
	  					alert("error");
	  				}
				}) 
		 })
		  $(".recovery").click(function(){
			  $.ajax({
	  				type:"get",
	  				url:"/htx-backer/recovery", 
	  				data:{
	  					name:"system_message"
	  				},
	  				success:function(data){
	  					if(data == "OK"){
	  						var btn = confirm("恢复成功,点击确定刷新列表!")
	  					 	if(btn == true){
			   					window.location.href="<%=request.getContextPath()%>/selectMessageList";
	  					 	}
	  					}else{
	  						alert("恢复失败!");
	  					}
	  				}
				}) 
		 })
	</script>
	
</body>
</html>
